//
//  ISpecCode.m
//  XRmenu
//
//  Created by yangxh on 11-3-24.
//  Copyright 2011 E0571. All rights reserved.
//

#import "ISpecCode.h"


@implementation ISpecCode

@synthesize checkInTime;
@synthesize code;
@synthesize Id;
@synthesize name;
@synthesize specCodeId;
@synthesize status;
@synthesize type;

//=========================================================== 
// - (id)init
//
//=========================================================== 
- (id)init
{
    return [self initWithCheckInTime:nil code:nil Id:0 name:nil specCodeId:nil status:0 type:0];
}


//=========================================================== 
// - (id)initWith:
//
//=========================================================== 
- (id)initWithCheckInTime:(NSDate*)aCheckInTime code:(NSString*)aCode Id:(NSInteger)anId name:(NSString*)aName specCodeId:(NSString*)aSpecCodeId status:(NSInteger)aStatus type:(NSInteger)aType 
{
    self = [super init];
    if (self) {
        self.checkInTime = aCheckInTime;
        self.code = aCode;
        self.Id = anId;
        self.name = aName;
        self.specCodeId = aSpecCodeId;
        self.status = aStatus;
        self.type = aType;
    }
    return self;
}


//=========================================================== 
// + (id)objectWith:
//
//=========================================================== 
+ (id)objectWithCheckInTime:(NSDate*)aCheckInTime code:(NSString*)aCode Id:(NSInteger)anId name:(NSString*)aName specCodeId:(NSString*)aSpecCodeId status:(NSInteger)aStatus type:(NSInteger)aType  
{
    id result = [[[self class] alloc] initWithCheckInTime:aCheckInTime code:aCode Id:anId name:aName specCodeId:aSpecCodeId status:aStatus type:aType];
	
    return [result autorelease];
}

//=========================================================== 
// - (NSArray *)keyPaths
//
//=========================================================== 
- (NSArray *)keyPaths
{
    NSArray *result = [NSArray arrayWithObjects:
					   @"checkInTime",
					   @"code",
					   @"Id",
					   @"name",
					   @"specCodeId",
					   @"status",
					   @"type",
					   nil];
	
    return result;
}


//=========================================================== 
// - (NSString *)descriptionForKeyPaths
//
//=========================================================== 
- (NSString *)descriptionForKeyPaths 
{
    NSMutableString *desc = [NSMutableString string];
    NSEnumerator *e = [[self keyPaths] objectEnumerator];
    NSString *thisKey;
    [desc appendString:@"\n\n"];
	
    while ((thisKey = [e nextObject])) {
        [desc appendFormat: @"%@: %@\n", thisKey, [self valueForKey:thisKey]];
    }
	
    return [NSString stringWithString:desc];
}

- (NSString *)description
{
	return [self descriptionForKeyPaths];
}

//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [checkInTime release];
    checkInTime = nil;
    [code release];
    code = nil;
    [name release];
    name = nil;
    [specCodeId release];
    specCodeId = nil;
	
    [super dealloc];
}

+ (ISpecCode *)iSpecCodeByParse:(NSDictionary *)info
{
	ISpecCode *specCode = [ISpecCode objectWithCheckInTime:[NSDate date]
													  code:dictObject(info,@"Code")
														Id:dictInt(info,@"ID")
													  name:dictObject(info,@"Name")
												specCodeId:dictObject(info,@"SpecCodeId")
													status:dictInt(info,@"Status")
													  type:dictInt(info,@"Type")];
	return specCode;
}

@end
